﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ttifa.Infrastructure.Utils;

namespace Ttifa.Log
{
    public class LogFactory
    {
        public static ILog GetLogger(string collectionName = "")
        {
            ILog log;
            var logType = (LogTarget)Enum.Parse(typeof(LogTarget), ConfigManager.GetSetting("LogTarget", "Nlog").ToLower());
            switch (logType)
            {
                case LogTarget.nlog: log = new NLog(); break;
                case LogTarget.mongodb:
                    {
                        if (string.IsNullOrEmpty(collectionName)) collectionName = ConfigManager.GetSetting("LogCollection");
                        log = new MongoLog(collectionName);
                    }
                    break;
                default: log = new NLog(); break;
            }

            return log;
        }
    }

    public enum LogTarget
    {
        nlog,
        mongodb
    }
}